package com.lhkj.ct.admin.modules.psychology.controller;

import com.lhkj.ct.base.annntation.Log;
import com.lhkj.ct.base.annntation.PreventDuplicateSubmit;
import com.lhkj.ct.base.enums.ActionType;
import com.lhkj.ct.base.model.ro.ActionResult;
import com.lhkj.ct.meta.modules.psychology.model.dto.SampleAnalysisDto;
import com.lhkj.ct.meta.modules.psychology.model.vo.AnalysisResult;
import com.lhkj.ct.meta.modules.psychology.service.SampleAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
  * <p>
  *     描述：样本分析
  * </p>
  */
@RestController
@RequestMapping("api/plat/psychology/sample/analysis")
@Api(tags = "2.5样本分析")
public class SampleAnalysisController {

    @Resource
    private SampleAnalysisService sampleAnalysisService;

    @PostMapping(value = "statistics")
    @ApiOperation(value = "统计")
    public ActionResult<AnalysisResult> statistics(@Validated @RequestBody SampleAnalysisDto entity) {
        return ActionResult.success(sampleAnalysisService.statistical(entity));
    }

    @PreventDuplicateSubmit
    @PostMapping(value = "export")
    @ApiOperation(value = "导出接口")
    @Log(title = "样本分析", actionType = ActionType.EXPORT, isSaveResponseData = false)
    public void exportWord(@RequestBody AnalysisResult entity) {
        sampleAnalysisService.exportWord(entity);
    }

}
